package com.wangjiyuan.giftshuo.ui.fragment.home;

import com.wangjiyuan.giftshuo.bean.search.HotBean;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by wjy on 2016/11/16.
 */

public class NavPresenter implements NavContract.NavPresenter {
    private NavContract.NavModel navModel = new NavModel();
    private NavContract.NavView navView = null;

    public NavPresenter(NavContract.NavView navView) {
        this.navView = navView;
    }

    @Override
    public void getHotWord() {
        Observable<HotBean> searchHot = navModel.getSearchHot();
        searchHot.observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Subscriber<HotBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HotBean hotBean) {
                        navView.search(hotBean.getData().getHotWords());
                    }
                });
    }
}
